﻿
using Common.EntityValidation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Test
{
        public class Program
        {
        

            static void Main()
            {
                var stu = new Student();

                stu.Birthday = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                stu.Score = 20;
                stu.StuState = 4;
                stu.IdCard = "620503199310130004518";
               stu.Introduce = "这是一堆个人aaaaaaaa介绍";





            
                var r = EntifyValidator.Validate(stu);

               Console.WriteLine($"验证结果{r.IsValid}");


              r.ValidResultDetails.ForEach((a) => {
                    Console.WriteLine(a.ErrorMessage + "\r\n");
                });

                Console.ReadKey();
            }
        }
        public class Student
        {

            [NotNull(ErrorMessage ="Id是必须的")]
            public string Id { get; set; }


        [Length(Max =10,ErrorMessage ="个人介绍的长度")]
        public string  Introduce { get; set; }  //个人介绍

        [Range(Min = 18,Max =100)]
            public int Age { get; set; }


            [Range(Max = "2100-10-10 00:00:00", Min = "1900-10-10 00:00:00")]
            public string Birthday { get; set; }


            [Range(Max = 100, Min = 1)]
            public Decimal Score { get; set; }

            [Chinese]
            public string Name { get; set; }



            [In(Range = "高中生,初中生,小学生")]
            public string StudentType { get; set; }

            [Mobile]
            public string CellPhone { get; set; }


            [Email]

            public string Email { get; set; }

            [IdCard]
            public string IdCard { get; set; }

            [InEnum(RangeType = typeof(StuState))]
            public int StuState { get; set; }


           

            [DbValidation(Sql = "select*from dbo.[data] where id=@ClassId")]  //班级Id
            public string ClassId { get; set; }
        }

        public enum StuState
        {

            上学中=0,
            肄业=2,
            退学=4,


        }
    }

